home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / mathstud.zip / ALL_TEST.M < prev    next >
Text File  |  1994-02-28  |  2KB  |  214 lines

  1. % Demonstration of MathViews syntax.
  2. % This file tests many MathViews features for compatibility
  3. % and enhancements.
  4. % Use the program menu to step through this file.
  5.  
  6. clear
  7. A=[1 2 3; 4 5 6; 7 8 0]
  8. x=[-1.3,4/5,4*atan(1)]
  9. B=A'
  10. C=A*B
  11. det(A)
  12. inv(A)
  13. inv(A)*A
  14. D=1:3:18
  15. D=1:4
  16. w=0:.1:.5
  17. w=0:0.1:0.5
  18. x=[1 2 3
  19.      4 5 6
  20.      0 9 0]
  21. any(x)
  22. all(x)
  23.  
  24. Y=sin(D)
  25. t=(0:8)'
  26.  
  27. x=-5:5+0.1
  28. y=sqrt(x)
  29. z=log(x+0.1)
  30. y.^2
  31.  
  32. x=eye(4)
  33. for col=x
  34.     col
  35. end
  36. x=[x col]
  37. size(x)
  38. ans
  39. [m,n]=size(x)
  40. m
  41. n
  42.  
  43. i=1
  44. while i<8
  45.       i=i+1
  46. end
  47. i=1
  48. while i<4
  49.      ++i
  50. end
  51.  
  52. x=6
  53. y=9
  54. z=3
  55. if y<x
  56.    z=2*z
  57. elseif z>x
  58.    z=3*z
  59. else
  60.    z=4*z
  61. end
  62.  
  63. if y<=x
  64.    z *= z
  65. end
  66.  
  67. x=[1:8;43:50;19:-1:12]
  68. y=x(1:2,1:2)
  69. x(1:2,:)
  70. y(:)
  71. x(:,1:4)
  72. x(:,8:-1:1)
  73. x(3:-1:1,8:-1:1)
  74. x(:,:)
  75. x(1:2,1:2)=x(1:2,4:5)
  76. x(:,1:2)=x(:,4:5)
  77.  
  78.  
  79. A=rand(5,3)/2000
  80. x=rand(3,1)/2000
  81. b=A*x
  82. A\b
  83. ans-x
  84.  
  85. fac(5)
  86.  
  87. t1=clock
  88. w=blackman(n)'
  89. t2=clock
  90. t2-t1
  91.  
  92. t1=clock
  93. w=blackman(n)'  % should be faster
  94. t2=clock
  95. t2-t1
  96.  
  97. x=6
  98. y=9
  99. z=2
  100. if y>x,  z=z*z; end
  101.  
  102. x=sqrt(-10.1:1:2)
  103. imag(x)
  104. imag(log(sqrt(x)))
  105.  
  106. % m-files
  107. n=5
  108.  
  109. x1=hilb(n)
  110. x2=invhilb(n)
  111. x1*x2
  112.  
  113. dft(1:n)
  114.  
  115. angle(sqrt(-1)+1)*2
  116. cov(1:8)
  117. isempty([])
  118. isempty(1:6)
  119. length([])
  120. length(1:19)
  121. length([1 2 3;4 5 6])
  122.  
  123. A=[1 2;3 4]
  124. B=[0 1;-1 0]
  125.  
  126. x=1:8
  127. x(1:8)
  128. %x(1:8,:) % should report an error
  129.  
  130. rem(1:9,2)
  131.  
  132. % logical operators
  133. 2 < 4
  134. x=1:8
  135. 4<x
  136.  
  137. % assignment
  138. x=zeros(3,4)
  139. y=1:12
  140. x(:)=y
  141.  
  142. %svd
  143. x=[1 2 3;4 6 1]
  144. [x1,x2,x3]= svd(x)
  145. x1'*x1
  146. x2'*x2
  147. x3'*x3
  148.  
  149. %matrix operations
  150. x=[1 2 3;4 5 6;7 8 9;10 11 12]
  151. x/3
  152. 3/x
  153. y=[2 3 2 ;3 4 3;4 5 4;5 6 5]
  154. x./y
  155. y./x
  156. x.\y
  157. y.\x
  158. a=[5 7 6 5;7 10 8 7;6 8 10 9;5 7 9 10]
  159. b=[23 32 33 31]'
  160. x=a\b
  161. a*x-b
  162. %a\(b')                % should report an error
  163. inv(a)
  164. a*inv(a)
  165.  
  166. %Jess
  167. A=[1:3;3:-1:1;4 7 1]
  168. B=[1 -1 -3 7;2 0 5 -5;3 1 7 3]
  169. X=A\B
  170.  
  171. who
  172. whos
  173. save ezdsp
  174. clear
  175. who
  176. whos
  177. load ezdsp
  178. who
  179. whos
  180.  
  181. % m-file to demonstrate graphics
  182. all_grp
  183.  
  184. % EZDSP enhancements
  185. x=[1:8;43:50;19:-1:12]   % working variable
  186.  
  187. % shifting
  188. x >> [1 2]
  189. x >> [-1 -2]
  190.  
  191. % rotation
  192. x <> [0 2]
  193. x <> [0 -2]
  194. x <> [1 2]
  195.  
  196. % C style assignments
  197. x= 1:6
  198. x += 3
  199. x -= 4
  200. x *= 3
  201. x /= 6
  202.  
  203. % user interaction
  204. pause(1)
  205. pause(5)
  206. pause
  207. velocity=input('enter value for velocity')
  208.  
  209. %invoke the editor
  210. !mathpad startup.m
  211.  
  212. disp('write to the output window')
  213. %error('Example of error reporting')
  214.